﻿(function (window, undefine) {
    var map_main = null;
    var image = '../../Content/Map/Images/YellowPin1LargeB.png';

    function initialize() {
        var mapOptions = {
            center: new google.maps.LatLng(15.120011, 108.808937),
            zoom: 6
        };

        map_main = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);

        var infoWindown = new google.maps.InfoWindow(
            {
                size: new google.maps.Size(250, 150)
            });

        google.maps.event.addListener(map_main, "click", function (event) {
            var marker = new google.maps.Marker({
                position: event.latLng,
                map: map_main,
                icon: image,
                draggable: true
            });

            google.maps.event.addListener(marker, "click", function () {
                infoWindown.setContent("Lat: " + marker.position.lat() + "<br>" +
                                       "Lon: " + marker.position.lng());
                infoWindown.open(map_main, marker);
            });
        });
    }


    //Initialize map
    google.maps.event.addDomListener(window, 'load', initialize);


})(window);